<?php
if(isset($_POST['submit_value']) && $_POST['submit_value']=='Change password')
{	
	if(Db::mysql_query(" UPDATE tbl_config SET config_content='".$_POST['password']."' WHERE config_name = 'password' ",FETCH_MODE_NONE))
		Common::header_location('index.php?page=logout');
}
?>

<script>
	function checkForm(){
		if($('#password').val()=='')
		{
			alert('Please input password!');
			$('#password').focus();
			return false;
		}
		if($('#password').val()!=$('#cpassword').val())
		{
			alert('Confirm password must equal to password. Please input confirm password again!');
			$('#cpassword').focus();
			return false;
		}
	}
</script>

<form method='post' onsubmit='return checkForm()'>
	<div style='margin:auto;width:330px'>
		<label>
			Password<br/>
			<input type='password' name='password' id='password'/>
		</label>
		<br/>
		<label>
			Confirm password<br/>
			<input type='password' id='cpassword'/>
		</label>
		<input type='submit' name='submit_value' value='Change password'/>
	</div>
</form>